package com.qf.controller;

import cn.dsna.util.images.ValidateCode;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 生成消费者登录页面的验证码
 * @author hanjiejie
 * @version V1.0
 * @Project java2203
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/5/23 17:40
 */
@WebServlet("/code")
public class CodeController extends  BaseServlet {

 public void createCode(HttpServletRequest request, HttpServletResponse response) throws IOException {

     //1.创建验证码
     ValidateCode validateCode = new ValidateCode(100,50,1,2);
     //获取验证码的内容
     String code = validateCode.getCode();
     //将验证码保存在会话中
     request.getSession().setAttribute("code", code);
     //将验证码图片留到页面中
     validateCode.write(response.getOutputStream());
 }
}
